var layer = layui.layer
    ,table = layui.table
    ,$ = layui.jquery
    ,processKey=getQueryVariable("processKey");
window.sessionStorage.setItem("processKey",processKey);
 table.render({
    elem: '#todo'
     ,where:{
         "processKey":processKey
     }
     ,typ:"get"
     ,url:"process/queryToDoTasks"
    ,cols: [[
        {field:'processDfName', title:'审批类型'}
        ,{field:'name', title:'当前界面'}
        ,{field:'createtime', title:'申请时间',sort:true}
        ,{field:'startUser', title:'申请人'}
        /*,{field:'businessKey', title:'单据编码'}*/
        ,{field:'code', title:'单据编码'}
        ,{field:'totalCost', title:'业务单据总额'}
        ,{fixed: 'right', align:'center', toolbar: '#todoeditor', title:'操作'}
    ]]
    ,id: 'todotableid'
    ,height: $(document).height() - $('#todo').offset().top - 50
    ,page: true
});

//监听工具条
table.on('tool(todo)', function(obj){
    var processId=obj.data.processInstanceId;
    var taskId=obj.data.taskid;
    getBusskey(processId,taskId,obj.event);


   /* var data = obj.data;
    if(obj.event === 'dealwith'){
        parent.intab("views/jsp/SystemCenter/tpl/approvalprocess.jsp?id="+data.id,"审批流程处理")
    }*/
});
function getBusskey(processId,taskId,event) {
    var busskey="";
    var formkey="";
    $.ajax({
        type : 'get',
        //  url : 'resource/getTree',
        data: {"taskId":taskId},
        url:'process/getFormInfo',
        dataType:"json",
        // contentType: 'application/json',
        async:false,
        success : function (da) {
            if(da.status==200 ){
                busskey=da.data.businesskey;
                formkey=da.data.formkey;
            }
        },
        error: function(data) {
            // layer.msg("获取失败!");
        }
    });
    if(event=="dealwith"){
        parent.intab("views/jsp/SystemCenter/tpl/approvalprocess.jsp?processId="+processId+"&busskey="+busskey+"&formkey="+formkey+"&taskId="+taskId,"审批流程处理")
        //parent.intab("views/jsp/SystemCenter/sp.jsp?processId="+processId+"&busskey="+busskey+"&formkey="+formkey+"&taskId="+taskId,"流程处理");
    }

}